package com.example.learn.controller;

import com.example.learn.bean.User;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class IndexController {

    // 实体类必须有get/set
    @PostMapping("/testValidate")
    public String testValidate(@Validated @RequestBody User user) {
        System.out.println(user);
        return "testValidate";
    }

    @GetMapping("/index")
    public String index() {
        return "weimin index";
    }

    @GetMapping("/test")
    public String test() {
        return "weimin test";
    }
}